/* eslint max-lines: "off" */ //临时豁免 关闭ESLint的最大代码行数max-lines规则
import { getDetailPackingconfigDetail } from '@/api/admin/productpackingconfig';
/**
 * 获取原材料标签打印配置
 */
export const getRawMaterialOption = (safe) => {
  return {
    labelPosition: 'right',
    labelWidth: 120,
    // menuBtn: true,
    submitBtn: true,
    submitText: '生成标签',
    emptyBtn: false,
    menuPosition: 'right',
    column: [
      {
        label: '单据号',
        prop: 'sheetNo',
        type: 'search',
        span: 12,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openCommonModal('sheetNoModal');
        }
      },
      {
        label: '供应商名称',
        prop: 'vendorName',
        span: 12,
        disabled: true,
        placeholder: '供应商名称'
      },
      {
        label: '供应商代码',
        prop: 'vendorCode',
        span: 12,
        disabled: true,
        placeholder: '供应商代码'
      },
      {
        label: '物料名称',
        prop: 'partName',
        span: 12,
        disabled: true,
        placeholder: '物料名称'
      },
      {
        label: '物料编码',
        prop: 'partNo',
        span: 12,
        disabled: true,
        placeholder: '物料编码'
      },
      {
        label: '物料规格',
        prop: 'partModel',
        span: 12,
        disabled: true,
        placeholder: '物料规格'
      },
      {
        label: '收料数量',
        prop: 'receiveQuantity',
        span: 12,
        disabled: true,
        placeholder: '收料数量'
      },
      {
        label: '实收数量',
        prop: 'actuallyReceive',
        disabled: true,
        span: 12
      },
      {
        label: '本次生成数量',
        prop: 'generationQuantity',
        placeholder: '请输入 本次生成数量',
        span: 12,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      {
        label: '已生成数量',
        prop: 'quantityPrinted',
        disabled: true,
        span: 12
      },
      {
        label: '条码规则',
        prop: 'sequenceName',
        type: 'search',
        placeholder: '请选择 条码规则',
        span: 12,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openSerialnoCommonModal();
        }
      },
      {
        label: 'MPQ',
        prop: 'mpq',
        span: 12,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      {
        label: '生产日期',
        prop: 'vendorDate',
        type: 'date',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        span: 12,
        placeholder: '请选择 生产日期',
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      {
        label: '供应商批次',
        prop: 'vendorLotNo',
        span: 12
      },
      {
        label: '备注',
        prop: 'description',
        type: 'textarea',
        minRows: 3,
        maxRows: 3,
        span: 12
      }
    ]
  };
};

/**
 * 获取原料打印-其他配置
 */
export const getRawMaterialOtherOption = (safe) => {
  return {
    labelPosition: 'right',
    labelWidth: 120,
    // menuBtn: true,
    submitBtn: true,
    submitText: '生成标签',
    emptyBtn: false,
    menuPosition: 'right',
    column: [
      {
        label: '收料记录',
        prop: 'receiveRecord',
        span: 12,
        type: 'search',
        disabled: true,
        placeholder: '请选择 收料记录',
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openCommonModal('otherReceiveMoal');
        }
      },
      {
        label: '物料编码',
        prop: 'partNo',
        span: 12,
        disabled: true,
        placeholder: '请选择 物料编码'
        // rules: [
        //     {
        //         required: true,
        //         trigger: "submit",
        //         validator: (rule, value, callback) => {
        //             callback();
        //         }
        //     }
        // ],
        // appendClick: () => {
        //     safe.openPartCommonModal();
        // }
      },
      {
        label: '物料名称',
        prop: 'partName',
        span: 12,
        disabled: true,
        placeholder: '物料名称'
      },
      {
        label: '物料规格',
        prop: 'partModel',
        span: 12,
        disabled: true,
        placeholder: '物料规格'
      },
      {
        label: '供应商代码',
        prop: 'vendorCode',
        span: 12,
        disabled: true,
        placeholder: '请选择 供应商代码'
        // rules: [
        //     {
        //         required: true,
        //         trigger: "submit",
        //         validator: (rule, value, callback) => {
        //             callback();
        //         }
        //     }
        // ],
        // appendClick: () => {
        //     safe.openVendorCommonModal();
        // }
      },
      {
        label: '供应商名称',
        prop: 'vendorName',
        span: 12,
        disabled: true,
        placeholder: '供应商名称'
      },
      {
        label: '收料数量',
        prop: 'receiveQuantity',
        disabled: true,
        span: 12
        // rules: [
        //     {
        //         required: true,
        //         trigger: "submit",
        //         validator: (rule, value, callback) => {
        //             callback();
        //         }
        //     }
        // ]
      },
      {
        label: '条码规则',
        prop: 'sequenceName',
        type: 'search',
        placeholder: '请选择 条码规则',
        span: 12,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openSerialnoCommonModal();
        }
      },
      {
        label: 'MPQ',
        prop: 'mpq',
        span: 12
        // disabled: true,
        // rules: [
        //     {
        //         required: true,
        //         trigger: "submit",
        //         validator: (rule, value, callback) => {
        //             callback();
        //         }
        //     }
        // ]
      },
      {
        label: '生产日期',
        prop: 'vendorDate',
        type: 'date',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        span: 12,
        placeholder: '请选择 生产日期',
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      {
        label: '供应商批次',
        prop: 'vendorLotNo',
        span: 12
      },
      {
        label: '备注',
        prop: 'description',
        type: 'textarea',
        minRows: 3,
        maxRows: 3,
        span: 12
      }
    ]
  };
};

/**
 * 物料补打标签配置
 */
export const getRawMaterialPatchFormOption = (safe) => {
  return {
    labelPosition: 'right',
    labelWidth: 120,
    // menuBtn: true,
    submitBtn: true,
    submitText: '生成标签',
    emptyBtn: false,
    menuPosition: 'right',
    column: [
      {
        label: '物料编码',
        prop: 'partNo',
        span: 12,
        type: 'search',
        disabled: true,
        placeholder: '请选择 物料编码',
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openPartCommonModal();
        }
      },
      {
        label: '物料名称',
        prop: 'partName',
        span: 12,
        disabled: true,
        placeholder: '物料名称'
      },
      {
        label: '物料规格',
        prop: 'partModel',
        span: 12,
        disabled: true,
        placeholder: '物料规格'
      },
      {
        label: '供应商代码',
        prop: 'vendorCode',
        type: 'search',
        span: 12,
        disabled: true,
        placeholder: '请选择 供应商代码',
        appendClick: () => {
          safe.openVendorCommonModal();
        }
      },
      {
        label: '供应商名称',
        prop: 'vendorName',
        span: 12,
        disabled: true,
        placeholder: '供应商名称'
      },
      {
        label: '供应商批次',
        prop: 'vendorLotNo',
        span: 12
      },
      {
        label: 'MPQ',
        prop: 'mpq',
        span: 12,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      {
        label: '生产日期',
        prop: 'vendorDate',
        type: 'date',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        span: 12,
        placeholder: '请选择 生产日期',
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      {
        label: '生成数量',
        prop: 'receiveQuantity',
        span: 12,
        placeholder: '请输入 生成数量',
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      {
        label: '条码规则',
        prop: 'sequenceName',
        type: 'search',
        placeholder: '请选择 条码规则',
        span: 12,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openSerialnoCommonModal();
        }
      },
      {
        label: '备注',
        prop: 'description',
        type: 'textarea',
        minRows: 3,
        maxRows: 3,
        span: 12
      }
    ]
  };
};

/**
 * 获取序列号生成及打印配置
 */
export const getSerialnoCreateOption = (safe) => {
  return {
    labelPosition: 'right',
    labelWidth: 130,
    // menuBtn: true,
    submitBtn: true,
    submitText: '生成序列号',
    emptyBtn: false,
    menuPosition: 'right',
    column: [
      {
        type: 'search',
        label: '工单号',
        prop: 'workOrderNo',
        span: 24,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openWorkorderCommonModal();
        }
      },
      {
        type: 'input',
        label: '产品编码',
        prop: 'partNo',
        span: 24,
        disabled: true,
        placeholder: '产品编码'
      },
      {
        type: 'input',
        label: '产品名称',
        prop: 'partName',
        span: 24,
        disabled: true,
        placeholder: '产品名称'
      },
      {
        type: 'input',
        label: '产品型号',
        prop: 'partModel',
        span: 24,
        disabled: true,
        placeholder: '产品型号'
      },
      {
        type: 'input',
        label: '客户料号',
        prop: 'customerPartNo',
        span: 24,
        disabled: true,
        placeholder: '客户料号'
      },
      {
        type: 'input',
        label: '生产总数',
        prop: 'quantity',
        span: 24,
        disabled: true,
        placeholder: '生产总数'
      },
      {
        type: 'search',
        label: '条码规则',
        prop: 'sequenceName',
        span: 24,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openSerialnoCommonModal();
        }
      },
      {
        type: 'input',
        label: '已生成序列号总数',
        prop: 'total',
        span: 24,
        disabled: true,
        placeholder: '已生成序列号总数'
      },
      {
        label: '生成数量',
        prop: 'produceQuantity',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      }
    ]
  };
};

/**
 * 获取序列号增补配置
 */
export const getSerialnoAppendOption = (safe) => {
  return {
    labelPosition: 'right',
    labelWidth: 130,
    // menuBtn: true,
    submitBtn: true,
    submitText: '增补序列号',
    emptyBtn: false,
    menuPosition: 'right',
    column: [
      {
        type: 'search',
        label: '工单号',
        prop: 'workOrderNo',
        span: 24,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openWorkorderCommonModal();
        }
      },
      {
        type: 'input',
        label: '产品编码',
        prop: 'partNo',
        span: 24,
        disabled: true,
        placeholder: '产品编码'
      },
      {
        type: 'input',
        label: '产品名称',
        prop: 'partName',
        span: 24,
        disabled: true,
        placeholder: '产品名称'
      },
      {
        type: 'input',
        label: '产品型号',
        prop: 'partModel',
        span: 24,
        disabled: true,
        placeholder: '产品型号'
      },
      {
        type: 'input',
        label: '客户料号',
        prop: 'customerPartNo',
        span: 24,
        disabled: true,
        placeholder: '客户料号'
      },
      {
        type: 'input',
        label: '生产总数',
        prop: 'quantity',
        span: 24,
        disabled: true,
        placeholder: '生产总数'
      },
      {
        type: 'search',
        label: '条码规则',
        prop: 'sequenceName',
        span: 24,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openSerialnoCommonModal();
        }
      },
      {
        type: 'input',
        label: '已生成序列号总数',
        prop: 'total',
        span: 24,
        disabled: true,
        placeholder: '已生成序列号总数'
      },
      // {
      //     label: '起始序列号',
      //     prop: 'startingSerialNo',
      //     span: 24,
      //     disabled: true
      // },
      {
        label: '序列号数量',
        prop: 'produceQuantity',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      {
        label: '原因说明',
        prop: 'remark',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      }
    ]
  };
};

/**
 * 获取报废序列号配置
 */
export const getSerialnoScrapOption = (safe) => {
  return {
    labelPosition: 'right',
    labelWidth: 120,
    // menuBtn: true,
    submitBtn: true,
    submitText: '报废序列号',
    emptyBtn: false,
    menuPosition: 'right',
    column: [
      {
        type: 'search',
        disabled: true,
        label: '工单号',
        prop: 'workOrderNo',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openWorkorderCommonModal();
        }
      },
      {
        type: 'input',
        label: '产品编码',
        prop: 'partNo',
        span: 24,
        disabled: true,
        placeholder: '产品编码'
      },
      {
        type: 'input',
        label: '产品名称',
        prop: 'partName',
        span: 24,
        disabled: true,
        placeholder: '产品名称'
      },
      {
        type: 'input',
        label: '产品型号',
        prop: 'partModel',
        span: 24,
        disabled: true,
        placeholder: '产品型号'
      },
      {
        type: 'input',
        label: '客户料号',
        prop: 'customerPartNo',
        span: 24,
        disabled: true,
        placeholder: '客户料号'
      },
      {
        type: 'input',
        label: '生产总数',
        prop: 'quantity',
        span: 24,
        disabled: true,
        placeholder: '生产总数'
      },
      // {
      //     type: 'search',
      //     label: '条码规则',
      //     prop: 'sequenceName',
      //     span: 24,
      //     readonly: true,
      //     rules: [
      //         {
      //             required: true,
      //             trigger: "submit",
      //             validator: (rule, value, callback) => {
      //                 callback();
      //             }
      //         },
      //     ],
      //     appendClick: () => {
      //         safe.openSerialnoCommonModal();
      //     }
      // },
      {
        label: '起始序列号',
        prop: 'startingSerialNo',
        type: 'search',
        disabled: true,
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          if (safe.serialnoScrapForm.workOrderId) {
            safe.openSerialnoRecordCommonModal(safe.serialnoScrapForm.workOrderId);
          } else {
            safe.$message({
              type: 'warning',
              message: '请选择工单号！'
            });
          }
        }
      },
      {
        label: '结尾序列号',
        prop: 'endSerialNo',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      // {
      //     label: '序列号数量',
      //     prop: 'produceQuantity',
      //     span: 24,
      //     disabled: true
      // },
      {
        label: '原因说明',
        prop: 'remark',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      }
    ]
  };
};

/**
 * 一对一序列号置换配置
 */
// export const getSerialnoReplaceOption = () => {
//     return {
//         labelPosition: 'right',
//         labelWidth: 120,
//         // menuBtn: true,
//         submitBtn: true,
//         submitText: '一对一序列号置换',
//         emptyBtn: false,
//         menuPosition: 'right',
//         column: [
//             {
//                 type: 'input',
//                 label: '旧产品序列号',
//                 prop: 'productSerialNo',
//                 span: 24,
//             },
//             {
//                 type: 'input',
//                 label: '工单号',
//                 prop: 'workOrderNo',
//                 disabled: true,
//                 span: 24,
//             },
//             {
//                 type: 'input',
//                 label: '产品编码',
//                 prop: 'partNo',
//                 span: 24,
//                 disabled: true
//             },
//             {
//                 type: 'input',
//                 label: '产品名称',
//                 prop: 'partName',
//                 span: 24,
//                 disabled: true
//             },
//             {
//                 type: 'input',
//                 label: '产品型号',
//                 prop: 'partModel',
//                 span: 24,
//                 disabled: true
//             },
//             {
//                 type: 'input',
//                 label: '客户料号',
//                 prop: 'customerPartNo',
//                 span: 24,
//                 disabled: true
//             },
//             {
//                 type: 'input',
//                 label: '生产总数',
//                 prop: 'productQuantity',
//                 span: 24,
//                 disabled: true
//             },
//             {
//                 type: 'input',
//                 label: '条码规则',
//                 prop: 'sequenceName',
//                 span: 24,
//                 disabled: true,
//             },
//             {
//                 type: 'input',
//                 label: '处理人',
//                 prop: 'logonName',
//                 span: 24,
//                 rules: [
//                     {
//                         required: true,
//                         message: "请输入处理人",
//                         trigger: "blur",
//                     },
//                 ]
//             },
//             {
//                 type: 'input',
//                 label: '原因说明',
//                 prop: 'remark',
//                 span: 24,
//                 rules: [
//                     {
//                         required: true,
//                         message: "请输入原因说明",
//                         trigger: "blur",
//                     },
//                 ]
//             },
//         ]
//     }
// }

/**
 * 序列号批量置换配置
 */
export const getSerialnoReplaceOption = (safe) => {
  return {
    labelPosition: 'right',
    labelWidth: 120,
    // menuBtn: true,
    submitBtn: true,
    submitText: '序列号置换',
    emptyBtn: false,
    menuPosition: 'right',
    column: [
      {
        type: 'search',
        disabled: true,
        label: '工单号',
        prop: 'workOrderNo',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openWorkorderCommonModal();
        }
      },
      {
        type: 'input',
        label: '产品编码',
        prop: 'partNo',
        span: 24,
        disabled: true
      },
      {
        type: 'input',
        label: '产品名称',
        prop: 'partName',
        span: 24,
        disabled: true
      },
      {
        type: 'input',
        label: '产品型号',
        prop: 'partModel',
        span: 24,
        disabled: true
      },
      {
        type: 'input',
        label: '客户料号',
        prop: 'customerPartNo',
        span: 24,
        disabled: true
      },
      {
        type: 'input',
        label: '生产总数',
        prop: 'quantity',
        span: 24,
        disabled: true
      },
      // {
      //     type: 'input',
      //     label: '条码规则',
      //     prop: 'sequenceName',
      //     span: 24,
      //     disabled: true,
      // },
      {
        type: 'search',
        disabled: true,
        label: '起始序列号',
        prop: 'startingSerialNo',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          if (safe.serialnoReplaceForm.workOrderId) {
            safe.openSerialnoRecordCommonModal(safe.serialnoReplaceForm.workOrderId);
          } else {
            safe.$message({
              type: 'warning',
              message: '请选择工单号！'
            });
          }
        }
      },
      {
        type: 'input',
        label: '结尾序列号',
        prop: 'endSerialNo',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      // {
      //     type: 'number',
      //     label: '序列号数量',
      //     controls: true,
      //     prop: 'produceQuantity',
      //     span: 24,
      //     disabled: true
      // },
      {
        type: 'input',
        label: '原因说明',
        controls: true,
        prop: 'remark',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      }
    ]
  };
};

/**
 * 成品包装条码创建配置
 */
export const getPackIdCreateOption = (safe) => {
  return {
    labelPosition: 'right',
    labelWidth: 130,
    // menuBtn: true,
    submitBtn: true,
    submitText: '生成包装条码',
    emptyBtn: false,
    menuPosition: 'right',
    column: [
      {
        type: 'search',
        label: '工单号',
        prop: 'workOrderNo',
        span: 24,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openWorkorderCommonModal();
        },
        change: (val) => {
          if (!val.value) {
            safe.model.partNo = '';
            safe.model.partName = '';
            safe.model.partModel = '';
            safe.model.quantity = '';
            safe.model.packingConfigDetailId = '';
            safe.packIdCreateOption.column[5].dicData = [];
          }
        }
      },
      {
        label: '产品编码',
        prop: 'partNo',
        span: 24,
        disabled: true,
        placeholder: '产品编码'
      },
      {
        label: '产品名称',
        prop: 'partName',
        span: 24,
        disabled: true,
        placeholder: '产品名称'
      },
      {
        label: '产品型号',
        prop: 'partModel',
        span: 24,
        disabled: true,
        placeholder: '产品型号'
      },
      {
        label: '生产总数',
        prop: 'quantity',
        span: 24,
        disabled: true,
        placeholder: '生产总数'
      },
      {
        label: '包装层级',
        prop: 'packingConfigDetailId',
        type: 'tree',
        dicData: [],
        props: {
          label: 'title',
          value: 'id'
        },
        span: 24,
        placeholder: '包装层级',
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        change: (val) => {
          if (val.value) {
            getDetailPackingconfigDetail(val.value).then(
              (res) => {
                safe.packIdCreateForm.mpq = safe._get(res, 'data.data.packingQuantity', '');
                safe.packIdCreateForm.sequenceDefinitionId = safe._get(res, 'data.data.sequenceDefinitionId', '');
                let number = Math.floor(safe.packIdCreateForm.quantity / safe.packIdCreateForm.mpq);
                let surplus = safe.packIdCreateForm.quantity % safe.packIdCreateForm.mpq;
                if (surplus > 0) {
                  safe.packIdCreateForm.estimateQuantity = number + 1;
                } else {
                  safe.packIdCreateForm.estimateQuantity = number;
                }
                safe.packIdCreateForm.createQuantity = '';
                safe.getSequencedefinitionDetail(safe.packIdCreateForm.sequenceDefinitionId);
                safe.getStartOrEndSequenceNumber(safe.packIdCreateForm.sequenceDefinitionId);
                safe.getPackingSequenceRecord();
              },
              (error) => {
                safe.packIdCreateForm.estimateQuantity = '';
              }
            );
          } else {
            safe.packIdCreateForm.mpq = '';
            safe.packIdCreateForm.estimateQuantity = '';
            // safe.model.surplusQuantity = '';
            safe.packIdCreateForm.createQuantity = '';
            safe.packIdData = [];
          }
        }
      },
      {
        label: '包装规格',
        prop: 'mpq',
        span: 24,
        disabled: true,
        placeholder: '包装规格'
      },
      {
        label: '预计数量',
        prop: 'estimateQuantity',
        span: 24,
        disabled: true,
        placeholder: '预计数量'
      },
      // {
      //     label: '剩余可打印数量',
      //     prop: 'surplusQuantity',
      //     span: 24,
      //     disabled: true,
      //     placeholder: '剩余可打印数量'
      // },
      {
        label: '生成数量',
        prop: 'createQuantity',
        span: 24,
        placeholder: '生成数量',
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      }
    ]
  };
};

/**
 * 成品包装条码增补配置
 */
export const getPackIdAppendOption = (safe) => {
  return {
    labelPosition: 'right',
    labelWidth: 130,
    // menuBtn: true,
    submitBtn: true,
    submitText: '增补包装条码',
    emptyBtn: false,
    menuPosition: 'right',
    column: [
      {
        type: 'search',
        label: '工单号',
        prop: 'workOrderNo',
        span: 24,
        disabled: true,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        appendClick: () => {
          safe.openWorkorderCommonModal();
        },
        change: (val) => {
          if (!val.value) {
            safe.model.partNo = '';
            safe.model.partName = '';
            safe.model.partModel = '';
            safe.model.quantity = '';
            safe.model.packingConfigDetailId = '';
            safe.packIdCreateOption.column[5].dicData = [];
          }
        }
      },
      {
        label: '产品编码',
        prop: 'partNo',
        span: 24,
        disabled: true,
        placeholder: '产品编码'
      },
      {
        label: '产品名称',
        prop: 'partName',
        span: 24,
        disabled: true,
        placeholder: '产品名称'
      },
      {
        label: '产品型号',
        prop: 'partModel',
        span: 24,
        disabled: true,
        placeholder: '产品型号'
      },
      {
        label: '生产总数',
        prop: 'quantity',
        span: 24,
        disabled: true,
        placeholder: '生产总数'
      },
      {
        label: '包装层级',
        prop: 'packingConfigDetailId',
        type: 'tree',
        dicData: [],
        props: {
          label: 'title',
          value: 'id'
        },
        span: 24,
        placeholder: '包装层级',
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ],
        change: (val) => {
          if (val.value) {
            getDetailPackingconfigDetail(val.value).then(
              (res) => {
                safe.packIdAppendForm.mpq = safe._get(res, 'data.data.packingQuantity', '');
                safe.packIdAppendForm.sequenceDefinitionId = safe._get(res, 'data.data.sequenceDefinitionId', '');
                let number = Math.floor(safe.packIdAppendForm.quantity / safe.packIdAppendForm.mpq);
                let surplus = safe.packIdAppendForm.quantity % safe.packIdAppendForm.mpq;
                if (surplus > 0) {
                  safe.packIdAppendForm.estimateQuantity = number + 1;
                } else {
                  safe.packIdAppendForm.estimateQuantity = number;
                }
                safe.packIdAppendForm.createQuantity = '';
                safe.getSequencedefinitionDetail(safe.packIdAppendForm.sequenceDefinitionId);
                safe.getStartOrEndSequenceNumber(safe.packIdAppendForm.sequenceDefinitionId);
                safe.getPackingSequenceRecord();
              },
              (error) => {
                safe.packIdAppendForm.estimateQuantity = '';
              }
            );
          } else {
            safe.packIdAppendForm.mpq = '';
            safe.packIdAppendForm.estimateQuantity = '';
            // safe.model.surplusQuantity = '';
            safe.packIdAppendForm.createQuantity = '';
            safe.packIdData = [];
          }
        }
      },
      {
        label: '包装规格',
        prop: 'mpq',
        span: 24,
        disabled: true,
        placeholder: '包装规格'
      },
      // {
      //     label: '起始包装条码',
      //     prop: 'startSequenceNumber',
      //     span: 24,
      //     disabled: true
      // },
      {
        label: '增补数量',
        prop: 'createQuantity',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      },
      {
        label: '原因说明',
        prop: 'description',
        span: 24,
        rules: [
          {
            required: true,
            trigger: 'submit',
            validator: (rule, value, callback) => {
              callback();
            }
          }
        ]
      }
    ]
  };
};
